<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>骡窝日报详情</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
	<script src="/js/plugins/jquery/jquery.min.js"></script>
	<script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
	<link rel="stylesheet" href="/css/reset.css">
	<link rel="stylesheet" href="/css/newsContent.css">
	<script src="/js/plugins/jrender/jrender.min.js"></script>
	<script src="/js/common.js"></script>
	<script>
        $(function () {
            var user = JSON.parse(sessionStorage.getItem("user"));
            var params = getParams();
            $.get("/favorites/"+user.id+ "/"+ params.id, function (data) {
                if (data){
                    $("#hart").attr("class",'fa fa-heart');
				}else{
                    $("#hart").attr("class",'fa fa-heart-o');
				}
			});
            $("#hart").click(function(){
                if ($(this).attr('class')=='fa fa-heart-o'){
                    $(this).attr("class",'fa fa-heart');
                    if ($(this).attr('class')=='fa fa-heart'){
						$.post("/favorites/"+user.id+ "/"+params.id , function(){
							alert("收藏成功");
						})
					}
                }
				else{
                    if ($(this).attr('class')=='fa fa-heart'){
						$(this).attr("class",'fa fa-heart-o');
                       	$.ajax({
							url: "/favorites/"+user.id+ "/"+params.id,
							type:"delete",
							success:function(){
								alert("取消收藏")
							}
						})
                    }
				}
			})
            if(params.id) {
                $.get("/daily/" + params.id, function (data) {
                    console.log(data);
                    $('.newsDetail').renderValues(data,{
                        getHref:function (item,value) {
                            var href = $(item).data("href");
                            $(item).attr("href",href+value);
                        }
					});
                })
            }
        });
	</script>
</head>
<body>
<div class="caption">

</div>
<div class="newsDetail">
	<div>
		<span>
			收藏<i id="hart" class="fa fa-heart-o"></i>
		</span>
		<a href="javascript:history.go(-1);" style="position: absolute;top: 38px;left: 22px;">
			<span><i class="fa fa-chevron-left fa-2x" style="color: black;"></i></span>
		</a>
		<a data-href="/dailyComment.html?dailyId=" render-key="id" render-fun="getHref">
			<img class="rounded" width="100%" height="110px"  render-src="coverUrl">
		</a>
		<div class="container">
			<div class="row typeRow">
				<div class="col-4">
					<span class="type" >美图美文</span>
				</div>
				<div class="col-4">
				</div>
				<div class="col-4">
					<span class="type">骡窝官方</span>
				</div>
			</div>

			<div class="detail">
				<h2 class="title" >名人眼中旅行的意义</h2>
				<div class="content" render-html="content.dailyContent"></div>
			</div>
		</div></div>
</div>

</body>
</html>